package at.ac.univie.zsu.aguataplan.domain;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Version;
import javax.validation.constraints.NotNull;

import org.springframework.format.annotation.DateTimeFormat;

/**
 * @author gerry
 * 
 */
@Entity
public class WorkingDescription {

	@Id
	@GeneratedValue(strategy = GenerationType.TABLE)
	@Column
	private Long id;

	@Version
	@Column
	private Integer version;

	@Temporal(TemporalType.TIMESTAMP)
	@DateTimeFormat(style = "M-")
	@Column
	private Date calDate;

	@NotNull
	@Column
	private String description;

	@ManyToOne
	private Ranking refRanking;

	@ManyToOne
	private Coach refCoach;

	@ManyToOne
	private Working refWorking;

	// ----------------------------------------------------
	// CONSTRUCTOR
	// ----------------------------------------------------

	public WorkingDescription() {

	}

	// ----------------------------------------------------
	// METHODS
	// ----------------------------------------------------

	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("CalDate: ").append(getCalDate()).append(", ");
		sb.append("Description: ").append(getDescription()).append(", ");
		sb.append("Id: ").append(getId()).append(", ");
		sb.append("RefCoach: ").append(getRefCoach()).append(", ");
		sb.append("RefRanking: ").append(getRefRanking()).append(", ");
		sb.append("RefWorking: ").append(getRefWorking()).append(", ");
		sb.append("Version: ").append(getVersion());
		return sb.toString();
	}

	// ----------------------------------------------------
	// GETTER & SETTER
	// ----------------------------------------------------

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Integer getVersion() {
		return version;
	}

	public void setVersion(Integer version) {
		this.version = version;
	}

	public Date getCalDate() {
		return calDate;
	}

	public void setCalDate(Date calDate) {
		this.calDate = calDate;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public Ranking getRefRanking() {
		return refRanking;
	}

	public void setRefRanking(Ranking refRanking) {
		this.refRanking = refRanking;
	}

	public Coach getRefCoach() {
		return refCoach;
	}

	public void setRefCoach(Coach refCoach) {
		this.refCoach = refCoach;
	}

	public Working getRefWorking() {
		return refWorking;
	}

	public void setRefWorking(Working refWorking) {
		this.refWorking = refWorking;
	}

}
